package com.heima.admin.controller.v1;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.common.constants.WemediaConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private IWemediaClient wemediaClient;


    @PostMapping("/list_vo")
    public ResponseResult findList(@RequestBody NewsAuthDto dto){
        return wemediaClient.findListNewsVo(dto);
    }

    @GetMapping("/one_vo/{id}")
    public ResponseResult findWmNewsVo(@PathVariable("id") Integer id){
        return wemediaClient.findWmNewsVo(id);
    }

    @PostMapping("/auth_pass")
    public ResponseResult updateByPass(@RequestBody NewsAuthDto dto){
        return wemediaClient.updateWmNewsStatus(WemediaConstants.WM_NEWS_AUTH_PASS,dto);
    }

    @PostMapping("/auth_fail")
    public ResponseResult updateByFail(@RequestBody NewsAuthDto dto){
        return wemediaClient.updateWmNewsStatus(WemediaConstants.WM_NEWS_AUTH_FAIL,dto);
    }
}
